package org.lanqiao.myUtils;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class Myutils {
	
	//建立日志控制台输出
	public static Log logger_console=LogFactory.getLog("systemOut");
	
	//建立日志文本输出
	public static Log logger_conFile=LogFactory.getLog("systemOut");
	
	
	/**
	 * 利用反射创建一个实例化对象的方法
	 * @param clazz
	 * @return
	 */
	public static Object getNewInstance(Class clazz){
		Object obj=null;
		try {
			obj=clazz.newInstance();
		} catch (InstantiationException | IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return obj;
	}

	public static Integer getInteger(Object ob){
		if(ob==null||ob.toString().trim().equals("")){
			return 0;
		}else{
			return Integer.valueOf((ob.toString().trim()));
		}
	}
	
	public static Long getLong(Object ob){
		if(ob==null||ob.toString().trim().equals("")){
			return (long) 0;
		}else{
			return Long.parseLong(ob.toString().trim());
		}
	}
	//获取整数
	public static int getInt(Object ob){
		if(ob==null||ob.toString().trim().equals("")){
			return 0;
		}else{
			return Integer.parseInt(ob.toString().trim());
		}
	}

}
